package org.example.shop.controller;

import jakarta.servlet.http.HttpSession;
import org.example.shop.entity.Admin;
import org.example.shop.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class AdminController {
    @Autowired
    private AdminService adminService;

    @GetMapping("/admin")
    public String admin(HttpSession session) {
        Object loginUser = session.getAttribute("loginUser");
        if (loginUser instanceof Admin && ((Admin) loginUser).getAccount().equals("admin")) {
            return "admin";
        }
        return "redirect:/";
    }
}